package com.ylr.blog.common.dto.blog_space;

import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.TreeSet;

/**
 * Created by IntelliJ IDEA.
 *
 * @author wyw
 * date: 2023-06-07 15:50:28
 * className: BlogSpaceDto
 * version: 1.0
 * description:
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
public class BlogSpaceDto implements Comparable<BlogSpaceDto> {

    /**
     * 空间主键
     */
    private String id;

    /**
     * 父级主键
     */
    private String parentId;

    /**
     * 父级路径
     */
    private String parentPath;

    /**
     * 空间名称
     */
    private String name;

    /**
     * 排序等级
     */
    private Integer sort;

    /**
     * 状态[0-可用 1-停用]
     */
    private Integer status;

    /**
     * 子空间集合
     */
    private TreeSet<BlogSpaceDto> children;

    @Override
    public int compareTo(BlogSpaceDto o) {
        int val = sort.compareTo(o.getSort());
        if (val == 0) {
            val = Long.valueOf(id).compareTo(Long.valueOf(o.getId()));
        }
        return val;
    }
}
